﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using log4net;
using TFXK.BLL;
using TFXK.Model;

public partial class Main : System.Web.UI.MasterPage
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly NewsBLL bllNews = new NewsBLL();
    int rowCount = 0;
    public string Keywords;
    public string Description;
    public string Hlable;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                SetMeta();
                BindLeftNews();

                if (Session["UserLogin"] == null)
                {
                    panIsLogin.Visible = false;
                    this.panNologin.Visible = true;
                }
                else
                {
                    panNologin.Visible = false;
                    panIsLogin.Visible = true;
                    lblUserName.Text = "你好," + ((Customs)Session["UserLogin"]).loginName + "欢迎登录!";
                }
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }
    //绑定文章
    public void BindLeftNews()
    {
        this.rptNewCJWT.DataSource = bllNews.GetList(15, 1, "lycjwt", out rowCount);
        rptNewCJWT.DataBind();
    }

    public void SetMeta()
    {
        if (Request.QueryString["Key"] != null)
        {
            int id = Int32.Parse(Request.QueryString["Key"].ToString());
            TFXK.Model.News model = bllNews.GetModel(id);

            this.Keywords = "\"" + model.title + "\"";
            this.Description = "\"" + model.description.Substring(15,100) + "\"";
            this.Hlable = model.title;
        }
        else
        {

            this.Keywords = "\"在线旅游咨询,旅游咨询服务,旅游咨询网,旅游咨讯,成都旅游咨询,四川旅游咨询,旅游咨询中心\"";
            this.Description = "\"下驿栈旅游网旅游咨询频道为您提供最好的旅游咨询服务,包括成都旅游咨询,四川旅游咨询,在线旅游咨询等旅游咨询信息与服务\"";
            this.Hlable = "旅游咨询,成都旅游咨询,旅游咨询网,四川旅游咨询服务中心,在线旅游咨询";
        }

    }
}
